package com.example.student.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 用户通知关联表
 */
@Data
@TableName("sys_user_notification")
public class SysUserNotification {
    
    /**
     * ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    
    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 通知ID
     */
    private Long notificationId;

    /**
     * 已读状态（0-未读，1-已读）
     * 数据库字段为read_status
     */
    @TableField("read_status")
    private Integer readStatus;
    
    /**
     * 阅读时间
     */
    private LocalDateTime readTime;
    
    /**
     * 创建时间
     */
    private LocalDateTime createdTime;
    
    /**
     * 兼容旧代码，将Integer映射到Boolean
     */
    public Boolean getIsRead() {
        return readStatus != null && readStatus == 1;
    }
    
    /**
     * 兼容旧代码，将Boolean映射到Integer
     */
    public void setIsRead(Boolean isRead) {
        this.readStatus = isRead != null && isRead ? 1 : 0;
    }
    
    /**
     * 获取已读状态
     */
    public Integer getReadStatus() {
        return readStatus;
    }
    
    /**
     * 设置已读状态
     */
    public void setReadStatus(Integer readStatus) {
        this.readStatus = readStatus;
    }
} 